<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="vue.js"></script>
    <style>
        td{
            border: 1px solid black;
            text-align: center;
        }
        th{
            border: 1px solid black;
        }
        table{
            width: 300px;
            border-collapse: collapse;
        }
    </style>
</head>
<body>
    <div id="app">
        <div class="search"> 
            按照价格查询: <input type="text" class="start"> - <input type="text" class="end">
            <button class="search-price">搜索</button> 按照商品名称查询: <input type="text" class="prodect">
            <button class="search-pro">查询</button>
            <button @click="getGoods"></button>
        </div>
        <table>
            <thead>
                <tr>
                    <th>id</th>
                    <th>产品名称</th>
                    <th>价格</th>
                </tr>
            </thead>
            <tbody>
                <tr v-for="(item,index) in goods" :key="index">
                    <td>{{item.id}}</td>
                    <td>{{item.pname}}</td>
                    <td>{{item.price}}</td>
                </tr>
            </tbody>
        </table>
    </div>

    <script>
        
        new Vue({
            el:'#app',
            data:{
                goods:[
                {id:1,pname:'小米',price: 3999},
                {id:2,pname:'OPPO',price: 999},
                {id:3,pname:'荣耀',price: 1299},
                {id:4,pname:'华为',price: 1999},
                
            ]
            },
            methods:{
                getGoods(goods){
                    console.log(this.goods);
                }
            }
            
        })
        var searchPrice = document.querySelector('.search-price');
        var start = document.querySelector('.start');
        var end = document.querySelector('.end');

        searchPrice.addEventListener('click',function(){
        //    var newGoods = this.goods.filter((item) =>{
        //         return item.price >= start.value && item.price <= start.value
        //     })
                var newGoods = this.goods.filter(function(value){
                return value.price >= start.value && value.price <= start.value
            })
            console.log(newGoods);
         })
        
    </script>
</body>
</html>